home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- '''Python implementation of persistent base types
-
- $Id: mapping.py 40332 2005-11-22 21:15:25Z tlotze $'''
- import persistent
- from UserDict import UserDict
-
- class PersistentMapping(UserDict, persistent.Persistent):
- '''A persistent wrapper for mapping objects.
-
- This class allows wrapping of mapping objects so that object
- changes are registered. As a side effect, mapping objects may be
- subclassed.
-
- A subclass of PersistentMapping or any code that adds new
- attributes should not create an attribute named _container. This
- is reserved for backwards compatibility reasons.
- '''
- __super_delitem = UserDict.__delitem__
- __super_setitem = UserDict.__setitem__
- __super_clear = UserDict.clear
- __super_update = UserDict.update
- __super_setdefault = UserDict.setdefault
- __super_pop = UserDict.pop
- __super_popitem = UserDict.popitem
-
- def __delitem__(self, key):
- self._PersistentMapping__super_delitem(key)
- self._p_changed = 1
-
-
- def __setitem__(self, key, v):
- self._PersistentMapping__super_setitem(key, v)
- self._p_changed = 1
-
-
- def clear(self):
- self._PersistentMapping__super_clear()
- self._p_changed = 1
-
-
- def update(self, b):
- self._PersistentMapping__super_update(b)
- self._p_changed = 1
-
-
- def setdefault(self, key, failobj = None):
- if not self.has_key(key):
- self._p_changed = 1
-
- return self._PersistentMapping__super_setdefault(key, failobj)
-
-
- def pop(self, key, *args):
- self._p_changed = 1
- return self._PersistentMapping__super_pop(key, *args)
-
-
- def popitem(self):
- self._p_changed = 1
- return self._PersistentMapping__super_popitem()
-
-
- def __iter__(self):
- return iter(self.data)
-
-
- def __getstate__(self):
- state = { }
- state.update(self.__dict__)
- state['_container'] = state['data']
- del state['data']
- return state
-
-
- def __setstate__(self, state):
- if state.has_key('_container'):
- self.data = state['_container']
- del state['_container']
- elif not state.has_key('data'):
- self.data = { }
-
- self.__dict__.update(state)
-
-
-